package com.tzpay.tzpay.db;

import java.io.File;

public class FileUtil
{
    /**
     * 删除文件/文件夹
     *
     * @param file
     *            要删除的根目录
     */
    public static void deleteFile(File file)
    {
        if (file.isFile())
        {
            file.delete();
            return;
        }
        if (file.isDirectory())
        {
            File[] childFile = file.listFiles();
            if (childFile == null || childFile.length == 0)
            {
                file.delete();
                return;
            }
            for (File f : childFile)
            {
                deleteFile(f);
            }
            file.delete();
        }
    }

    /**
     * 删除文件/文件夹
     *
     * @param path
     *            要删除的根目录
     */
    public static void deleteFile(String path)
    {
        File file = new File(path);
        deleteFile(file);
    }
}
